<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/26
 * Time: 11:57
 */

//创建内存表,1024行,其他子进程可以共享这么一个数据表
$table = new swoole_table(1024);

//内存表增加列,TYPE_INT整型
$table->column("id", $table::TYPE_INT, 4);
$table->column("name", $table::TYPE_STRING, 64);
$table->column("age", $table::TYPE_INT, 3);
//在内存中生成这张表
$table->create();

//增加一行内容,tommy_zou为key,key 是为了之后get调用用的
$table->set('tommy_zou', ['id' => 1, 'name' => 'tommy', 'age' => 30]);

//增加内容还有一个方案
$table['tommy_zou_1'] = ['id' => 2, 'name' => 'tommy_2', 'age' => 31];

//对数据的修改操作,age+2
//$table->incr('tommy_zou','age',2);
//对数据的修改操作,age-2
$table->decr('tommy_zou', 'age', 2);
print_r($table['tommy_zou']);

//删除一个key的数据
$table->del('tommy_zou');

//调用数据
//print_r($table->get('tommy_zou_1'));

//调用数据还可以
print_r($table['tommy_zou']);


